package cn.wang.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class UserServiceLogger {
    private static final Logger log = Logger.getLogger(UserServiceLogger.class);

    @Pointcut("execution(* cn.wang.dao.service.UserService.*(..))")
    public void pt(){}

    @After("pt()")
    public void afterLogger(JoinPoint jp) {
        log.info(jp.getSignature().getName() + "方法结束执行");
    }

    @Before("pt()")
    public void beforeLogger(JoinPoint jp) {
        log.info(jp.getSignature().getName() + "方法开始执行");
    }
}
